#ifndef NODEEDGE_H
#define NODEEDGE_H

#include"node_socket.h"
#include"node_scene.h"
#include"item_enum.h"
#include<QGraphicsPathItem>

/**
 * Edge 实际上也可以用一个map或者边表的方式储存
 */

class NodeEdge : public QGraphicsPathItem
{
public:
    NodeEdge();
    NodeEdge(NodeScene *start_node,NodeScene *end_node,NodeSocket *start_socket,NodeSocket *end_socket,QGraphicsItem *parent = nullptr);
    NodeEdge(NodeSocket *start_socket,NodeSocket *end_socket,QGraphicsItem *parent = nullptr);
    NodeEdge(const NodeEdge &nodeEdge);
    void operator=(const NodeEdge &nodeEdge);
    ~NodeEdge();
    int type() const override {return Type_NodeEdge;}

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
    QRectF boundingRect() const override;
    //QPainterPath shape() const override;

    void SetIndex(int index);
    void SetStartPos(NodeSocket *start_socket);
    void SetEndPos(NodeSocket *end_socket);

    QPointF start_pos;
    QPointF end_pos;
    QPainterPath *path;


    int index;
    NodeSocket *start_socket;
    NodeSocket *end_socket;
    NodeScene *start_node;
    NodeScene *end_node;

//    NodeItem *start_item;
//    NodeItem *end_item;
    QPointF start_socket_pos;
    QPointF end_socket_pos;

};

#endif // NODEEDGE_H
